<template>
	<view class="content">
		
		<view class="head">
			<!-- 搜索框 -->
			<u-row  customStyle="margin-bottom: 2px;height: 98rpx;">
				<u-col span="9" offset="1.5">
					<view class="search">
						<u-search  
						 searchIconColor='#fd4f02'
						 borderColor='#fd4f02'
						 bgColor='transparent' 
						 v-model="keyword" 
						 @change="getSearchBook(keyword)"
						 :show-action="false"
						 @focus="getSearchBook(keyword)"
						 @blur="changeAssClose"
						 @search="search(0)"
						 @clickIcon = "search(0)"
						 placeholder='搜索更多'
						 ></u-search>
					</view>
					
				</u-col>
			<!-- 	<u-col span="1"> 
					<view class="list-dot">
						<u-icon name="list-dot" size="30" @click="listDot"></u-icon>
					</view>
				</u-col> -->
			</u-row>
		<view class="AssociatioPosition"  v-if="AssociationListShow" >
			
			<scroll-view :class="'AssociatioList'+' '+[false?'AssociatioList1':'']"  scroll-y>
				<view v-for="(item,index) in AssociationList" class="item">
					<!--   <view id="{{item}}" bindtap="itemtap" class="itemview">{{item}}</view> -->
					<view  v-html="item.bookName" class="AssociationListItem" @click="associationFun(item)">
					</view>
				</view>
			</scroll-view>
		</view>
		<view class="daohanglan">
			<Tabs :tabsC="tabsC" @bindhandleItemChange="handleItemChange">
			    
			      
			</Tabs>
		</view>
		</view>
		
		
		
		<u-popup :show="show1" :round="10" mode="center" :closeOnClickOverlay='false' >
		   
				<view class="msg1">
					<view class="Title">
						请选择正确的校区，以确保展示不同校区的商品，若要修改，可到个人中心页面修改
					</view>
				<view class="button1">
					<u-button type="info" shape='circle' plain text="海珠校区"  color="#fd4f02"
					@click="getArea(0)"></u-button>
				</view>
				<view class="button2">
					<u-button type="info" shape='circle' plain text="白云校区"  color="#fd4f02"
					@click="getArea(1)"></u-button>
				</view>	
					
				</view>
		   
		</u-popup>
		
		
		<!-- 底部弹出层 -->
		<u-popup :show="typeshow" :round="10" mode="bottom"  @close="buttomShowClose" @open="open">
		    <view class="classify">
				<view class="first">
					<view class="firstFont">
						主要分类
					</view>
					<view class="firstClassify">
						<view class="firsButton">
							二手教材
						</view>
						<view class="firsButton">
							学习资料
						</view>
						<view class="firsButton">
							闲置物品
						</view>
					</view>
				</view>
		    </view>
		</u-popup>
		
		<u-popup :show="prePubShow" mode="bottom"  @close="closePre">
		        <view class="twohandbook1">
		        	<view class="progress_block" v-for="(item,index) in preList">
		        		<view class="describe" :class="'block'">
		        			<view class="name">{{item.bookName}}</view>
		        			<view class="bookInfo">ISBN编码：{{item.isbn}}</view>
		        			<view class="bookInfo">出版社：{{item.publisher}}</view>
		        			<view class="bookInfo">成色：{{item.chengse}}</view>
		        			<view class="bookInfo">数量：{{item.bookNumber}}</view>
		        			<view class="bookInfo">单价：￥{{item.price}}</view>
		        			<view class="bookInfo">预计收入：￥{{item.input}}</view>
		        		</view>
		        		<view class="charts-box arcbar" style="background-color: #FCFCFC;">
		        			<view class="buy">
		        				<u-icon name="close-circle" color="#3c9cff" size="30" labelPos="buttom" 
		        				@click="cancelPreBook()"></u-icon>
		        			</view>
		        		</view>
		        	</view>
		        </view>
		</u-popup>
		
		<!-- 发布弹出层 -->
		<u-popup :show="bookDetailShow" :safeAreaInsetBottom='false' :round="10" mode="center" @close="closeBookDetail">
		    <view class="bookDetail">
				<view class="msg">
					<view class="bookTitle">{{bookTitle}}</view>
					<view class="isbn">
						ISBN编码：{{bookIsbn}}
					</view>
					<view style="position: relative; margin-top: 33rpx;height: 90rpx; ">
						<view class="countBuyBookView">
							<uni-number-box v-model="bookNumber"
							 :min="1" :max="3"
							 buttonSize="40rpx"
							 @change="addNumber"
							  >
							 </uni-number-box>
						</view>
						<view class="fontCss">本</view>
					
					</view>
					<view class="bindweixin">
						<view class="lianxi">
							联系方式
						</view>
						<view class="input1">
							  <u--input  v-model="wxNum" placeholder="微信号/手机号" border="bottom" clearable ></u--input>
						</view>
						
					</view>
					<u-button type="primary" text="发布" color="#3c9cff"
					@click="ConfirmPublish(PublishForm,bookNumber)"></u-button>
				</view>
		    </view>
		</u-popup>
		<block v-if="tabsC[0].isActive">
			<view class="textCss">
				猜你想卖
			</view>
		<view class="twohandbook">
			<view class="progress_block" v-for="(item,index) in bookListShow">
				<view class="describe" :class="'block'">
					<view class="name1">{{item.bookName.length>14?item.bookName.substr(0,14)+'...':item.bookName}}</view>
					<view class="value">ISBN:{{item.isbn}}</view>
				</view>
				<view class="charts-box arcbar" style="background-color: #fff;">
					<view class="plus">
						<image  src="http://1.14.247.152:9797/images/16834icon_fabu.png" style="" mode="widthFix" @click="openBookDetail(item.bookName,item.publisher,item.isbn,item.id)"></image>
						
					</view>
				</view>
			</view>
		</view>
		</block>
		<block v-if="tabsC[1].isActive">
			
			<!-- <view class="uploadImg"> -->
				<u-upload
						:fileList="fileList1"
						@afterRead="afterRead"
						@delete="deletePic"
						name="1"
						multiple
						:maxCount="6"
						:previewFullImage="true"
				></u-upload>
			<!-- </view> -->
			
			<view class="goodDetailInput">
				<view class="title">标题</view>
				<!-- <input v-model="goodsData.goodName" maxlength=20 placeholder="请输入宝贝的名称"
					placeholder-style="color: #c5c5c5 "></input> -->
					<view class="input2">
						<u--input  v-model="goodsData.name" maxlength=20 placeholder="请输入宝贝的名称" border="bottom" clearable placeholderStyle="color: #c5c5c5 "></u--input>
					</view>
					
			</view>
			<view class="goodDetailInput" style="border-bottom: none;">
				<view class="title" style="line-height: 100rpx;">分类</view>
				<picker-view :indicator-style="indicatorStyle" indicator-class="selectLine" :value="value1"  @change="bindChange" >
					<picker-view-column>
						<view class="item" v-for="(item,index) in category" :key="index">{{item}}</view>
					</picker-view-column>
				</picker-view>
			</view>
			<view class="goodDetailInput">
				<view class="title">想卖￥</view>
				<!-- <input type="number" v-model="goodsData.goodName" maxlength=20 placeholder="想卖多少钱"
					placeholder-style="color: #c5c5c5 "></input> -->
					<view class="input2">
						<u--input type="number"  v-model="goodsData.price" maxlength=20 placeholder="想卖多少钱" border="bottom" clearable placeholderStyle="color: #c5c5c5 "></u--input>
					</view>
			</view>
			<!-- <view class="goodDetailInput" style="border-bottom: none;">
				<view class="title" style="line-height: 100rpx;">议价</view>
				<picker-view :indicator-style="indicatorStyle" indicator-class="selectLine" :value="value" @change="bindChange" >
					<picker-view-column>
						<view class="item" v-for="(item,index) in yijia" :key="index">{{item}}</view>
					</picker-view-column>
				</picker-view>
			</view> -->
			
			<view class="goodDetailInput">
				<view class="title">联系方式</view>
					<view class="input2">
						<u--input  v-model="goodsData.wxNumber" placeholder="微信号/手机号" placeholderStyle="color: #c5c5c5 " border="bottom" clearable ></u--input>
					</view>
			</view>
			<!-- 商品描述 -->
			<view class="goods_describe">
				<view class="title">宝贝描述</view>
				<textarea v-model="goodsData.detail" maxlength=150 @focus="" @blur=""
					:placeholder="goods_describe" placeholder-class="placeholderStyle">
				</textarea>
			</view>
			
			<button class="inputbtn" plain type="warn" @click="goodPublic">发布</button>
			
		</block>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				fileList1: [],
				value1:[0],
				goodsData: {
					classifyId: '',
					detail: '', 
					name: '', 
					price: '', 
					urls: [], 
					wxNumber:""
				},
				goods_describe: "描述你的宝贝，如规格、购买渠道、转手原因等，以及联系方式",
				indicatorStyle: `height: 30px`,
				schoolArea: ['海珠', '白云'], //学院
				yijia:['一口价','可刀'],
				category:['生活用品','体育器材','学习用品','其它'],
				wxNum:'',
				radiolist1: 
				[{
					name: '海珠校区',
					disabled: false
				  },
					{
					  name: '白云校区',
					  disabled: false
					}
				  ],
				location:"",
				chengseList:["8~9成新","5~7成新","3~4成新"],
				publisher:'',
				bookIsbn:'',
				bookChengse:'',
				bookId:'',
				realPrice:'',
				bookNumber: 1,
				totalPrice:'',
				bookTitle:'',
				defaultRadio:'',
				preList:[],
				keyword: '',
				show1:false,
				chubanshe:'',
				title: 'Hello',
				bookList: [],
				bookListShow: [],
				preScrollTop: '',
				showShopping: true,
				typeshow: false,
				prePubShow:false,
				screenHeightRpx: '',
				transitionStyle: '',
				bookDetailShow: false,
				bookDetailButtonCss: ["button","button","button"],
				bookDetailButtonIndex: "",
				AssociationList:'',
				AssociationListShow:false,
				LocationList:[],
				ChengseShow:false,//成色弹窗
				LocationShow:false,//地区弹窗
				PublishForm:{
					location:'选择地区',
					bookId:'',
				}
			}
		},
		computed: {
				bookListShow1: {
					get() {
						console.log('999999999',this.limitNumber(this.bookListShow))
						return this.limitNumber(this.bookListShow)
					},
					set(value) {
						console.log(this.bookListShow)
						this.$forceUpdate()
					
					}
				},
				tabsC:{
				 get(){
				  return [
				 {
				  id:0,
				  name:"二手教材",
				  isActive:true
				 },
				 {
				  id:1,
				  name:"闲置物品",
				  isActive:false
				 }
				]
				 },
				 set(){
				  this.$forceUpdate()
				 }
				 
				}
			},
		async onLoad() {
			uni.showLoading({
				title: '加载中'
			})
			wx.cloud.init({
				env:'prod-0g5m8v40aeec4be5'
			}
			)
			let vm = this
			let qua='';
			let header = new Object
			header.Authority = getApp().globalData.Authority
			let Location=await getApp().UniRequest(`/twohandbook/location/getLocation`,"GET","","")
			this.wxNum = this.goodsData.wxNumber = getApp().globalData.wxNumber
			console.log('wxNum',this.wxNum)
			console.log('发布页onload的Location',Location)
			this.LocationList=Location.data.data
			console.log('发布页onload的LocationList：',this.LocationList)
			let data = await getApp().UniRequest(`/twohandbook/userBook/authority/getNeedTextBookByChengse?chengse=qua&location= 0`,"GET","",header)
			console.log('data',data)
			vm.quickLogin()
			uni.getSystemInfo({
				success(res) {
					let screenWidth = res.screenWidth
					let screenHeight = res.screenHeight
					let ratio = 750/screenWidth
					let height = screenHeight * ratio
					getApp().globalData.screenHeightRpx = height
					console.log("rpx"+getApp().globalData.screenHeightRpx)
				}
			})
			this.getDefaultRadio()
			getApp().watch("screenHeightRpx",(data)=>{
				console.log("改变了="+data)
				this.transitionStyle = "top: "+data*0.67+"rpx;"
			})
			
		},
		async onshow(){
			console.log('发布页onshow')
		},
		onUnload() {
			console.log("关了")
		},
		onPageScroll : function(e) { //nvue暂不支持滚动监听，可用bindingx代替
			let vm = this
			if (e.scrollTop > vm.preScrollTop){
				vm.showShopping = false
			}else{
				vm.showShopping = true
			}
			vm.preScrollTop = e.scrollTop
		},
		methods: {
			async goodPublic(){
				let vm = this
				console.log('goodPublic11111111')
				let header = new Object
				header.Authority = getApp().globalData.Authority
				// console.log(reg.test(this.goodsData.price))
				if(this.goodsData.classifyId==''){
					this.goodsData.classifyId=this.value1[0]+1;
					
				}
				if(this.goodsData.urls.length==0){
					uni.showToast({
						 title: '请附上商品图片',
						 icon: 'error',
						 duration: 600
					});
					return
				}
				// console.log('this.goodsData.price',this.goodsData.price)
				// return
				if(this.goodsData.name==''){
					uni.showToast({
						 title: '请填写宝贝名称',
						 icon: 'error',
						 duration: 600
					});
					return
				}
				
				if(this.goodsData.price==''){
					uni.showToast({
						 title: '请填写价格',
						 icon: 'error',
						 duration: 600
					});
					return
				}
				let reg = /[^\d]/;
				if(reg.test(this.goodsData.price)==true){
					
					uni.showToast({
						 title: '请填写正确价格',
						 icon: 'error',
						 duration: 600
					});
					return
				}
				
				
				if(getApp().globalData.wxNumber!==this.goodsData.wxNumber){
					console.log('this.goodsData.wxNumber',this.goodsData.wxNumber)
					let data = await getApp().UniRequest("/twohandbook/user/authority/toBindWx?wxNumber="+vm.goodsData.wxNumber,"GET","",header)
					console.log('微信绑定',data)
					getApp().globalData.wxNumber=this.goodsData.wxNumber
				}
				let body  = vm.goodsData;
				console.log('header::::',header.Authority);
				let isBindWx = await getApp().UniRequest("/twohandbook/user/authority/isBindWx","GET","",header)
				if(isBindWx.code==20000){
										uni.showLoading({
											title: '发布中'
										})
										let res = await getApp().UniRequest("/twohandbook/goods/authority","PUT",body,header);
										console.log('闲置物品发布res：',res)
										if(res.code === 20000){
											setTimeout(()=>{
												uni.hideLoading()
												uni.showToast({
													title:'发布成功',
													duration:1700
												});
											},400)
										}else{
											uni.hideLoading()
											uni.showToast({
												 title: '发布失败',
												 icon: 'error',
												 duration: 400
											});
										}
				}
				else {
					wx.showToast({
					  title: '请填写联系方式',
					  icon: 'error',
					  duration: 800
					})
					return
				}
			},
			bindChange(e) {
				let value = e.detail.value; //获取当前选中项的下标
				this.goodsData.classifyId = value[0]+1;
				console.log("触发了bindChange")
				console.log(value[0])
			},
			// 删除图片
			deletePic(event) {
				this[`fileList${event.name}`].splice(event.index, 1)
				this.goodsData.urls.splice(event.index, 1)
			},
			// 新增图片
			async afterRead(event) {
				// 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				let fileListLen = this[`fileList${event.name}`].length
				lists.map((item) => {
					this[`fileList${event.name}`].push({
						...item,
						// status: 'uploading',
						// message: '上传中'
					})
				})
				for (let i = 0; i < lists.length; i++) {
					// const result = await this.uploadFilePromise(lists[i].url)
					console.log('图片路径：：：',i,lists[i].url)
					let urlCloudName = lists[i].url.split('/')[3];
					console.log('处理后的urlCloudName',urlCloudName);
					// wx.cloud.uploadFile({
					//   cloudPath: urlCloudName,
					//   filePath: lists[i].url, // 文件路径
					//   success: res => {
					//     console.log('成功之后的resID',res.fileID)
					//   },
					//   fail: err => {
					// 	console.log(err)
					//   }
					// })
					
					// cloud.uploadFile({
					//   cloudPath: urlCloudName, 
					//   filePath: lists[i].url, 
					//   config: {
					//     env: 'prod-0g5m8v40aeec4be5' 
					//   },
					//   success: res => {
					//     console.log('成功之后的resID',res.fileID)
					//   },
					//   fail: err => {
					//     console.error(err)
					//   }
					// })
					
					
				 wx.cloud.uploadFile({
					  cloudPath: urlCloudName, 
					  filePath: lists[i].url, 
					  config: {
					    env: 'prod-0g5m8v40aeec4be5' // 微信云托管环境ID
					  },
					    success: res => {
					      console.log('成功之后的resID',res.fileID)
						  this.goodsData.urls.push(res.fileID)
					    },
					    fail: err => {
					      console.error(err)
					    }
					})
					
					// cloud.uploadFile({
					//   cloudPath: urlCloudName,
					//   file: new File(), // 通过 input 或者 new File 获取
					//   config: {
					//     env: 'prod-0g5m8v40aeec4be5'
					//   },
					//   success: res => {
					//     console.log(res.fileID)
					//   },
					//   fail: err => {
					//     console.error(err)
					//   }
					// })
					
					// this.goodsData.urls.push(lists[i].url)
					// let item = this[`fileList${event.name}`][fileListLen]
					// this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
					// 	status: 'success',
					// 	message: '',
					// 	url: result
					// }))
					// fileListLen++
				}
			},
			uploadFilePromise(url) {
				return new Promise((resolve, reject) => {
					let a = uni.uploadFile({
						url: 'http://192.168.2.21:7001/upload', // 仅为示例，非真实的接口地址
						filePath: url,
						name: 'file',
						formData: {
							user: 'test'
						},
						success: (res) => {
							setTimeout(() => {
								resolve(res.data.data)
							}, 1000)
						}
					});
				})
			},			
			//自动登录函数
			async quickLogin(){
				let vm = this
				wx.login().then(async (res) =>{
					let body = new Object
					body.code = res.code
					let data = await getApp().UniRequest("/twohandbook/user/quicklyLogin","POST",body,"");
					console.log('我的发布里面的自动登录函数',data)
					if (data.code == 20000){
						getApp().globalData.Authority = data.data.Authority
						getApp().globalData.openid = data.data.openid
						vm.getMayPublish()
					}
				})
			},
			handleItemChange(index){
			    console.log('父组件接收到的index',index);
			    var arr = this.tabsC
			    console.log(this.tabsC)
			    this.tabsC = arr.forEach((v,i)=>i===index?v.isActive=true:v.isActive=false)
			   },
			async getArea(index){
				//console.log('@@@@@',index)
				getApp().globalData.location = this.location = index
				let header = new Object
				header.Authority = getApp().globalData.Authority
				let toBindLocation = await getApp().UniRequest("/twohandbook/user/authority/toBindLocation?location="+this.location,"GET","",header)
				console.log('getArea里面的toBindLocation',toBindLocation)
				// this.quickLogin()
				this.show1 = false
				wx.showTabBar()
				uni.getUserProfile({
					desc: '用于展示头像',
					async success(res) {
						let user = new Object()
						getApp().globalData.nickName =user.nickName = res.userInfo.nickName
						getApp().globalData.avatarUrl = user.avatarUrl = res.userInfo.avatarUrl
						getApp().globalData.user = user
						let body = new Object()
						body.nick_name = user.nickName
						body.avatar_url = user.avatarUrl
						let data = await getApp().UniRequest("/twohandbook/user/authority/updateNamePc","POST",body,header)
					}
				})
			},
			getDefaultRadio(){
			},
			async search(index){
				this.AssociationListShow=false
				console.log(index)
				let vm = this
				if (vm.keyword == ''){
					return
				}
				let header = new Object
				header.Authority = getApp().globalData.Authority
				let param = "?pattern="+vm.keyword+"&kind="+index
				uni.showLoading({
					title: '正在搜索'
				})
				let data = await getApp().UniRequest("/twohandbook/textbook/authority/fuzzyQuery"+param,"GET","",header)
				console.log('5555555555',data)
				uni.hideLoading()
				if (data.code == 20000){
					let list = data.data.list
					getApp().globalData.searchList = list
					if (list.length == 0){
						uni.showToast({
							title: '暂时找不到噢！',
							icon: 'error'
						})
					}else {
						uni.navigateTo({
							url: './publishSearch/publishSearch'
						})
					}
				}
				else{
					console.log('请求没有成功！')
				}
			},
			async getSearchBook(val) {
				console.log('this.keyword',this.keyword=='',typeof(this.keyword))
				
				if (this.keyword=='') {
					this.AssociationListShow = false;
					return
				}
				console.log(this.keyword);
				let Association = await getApp().UniRequest(`/twohandbook/textbook/associate?pattern=${this.keyword}`,
					"GET", "", "")
				console.log(Association)
				if (Association.code == 20000) {
					this.AssociationList = []
					// console.log(Association.data.data.length)
					for (let i = 0; i < Association.data.textbook.length && i<10; i++) {
						// console.log(Association.data[i])
						this.AssociationList.push(Association.data.textbook[i])
					}
					console.log('this.AssociationList联想:',this.AssociationList);
					this.AssociationListShow = true;
					// this.show = true;
					// this.displayClass = true;
					// console.log(this.AssociationList)	
				}
			},
			async associationFun(item){
				console.log('联想的内容被点击了',item)
				uni.showLoading({
					title: '搜索中'
				})
				let header = new Object
				header.Authority = getApp().globalData.Authority
				console.log('item.id',item.id)
				let param = "?kind=0"+"&id="+item.id
				let res = await getApp().UniRequest("/twohandbook/textbook/authority/clickOne"+param,"GET",'',header)
				console.log('res333333',res);
				if (res.code == 20000){
					uni.hideLoading()
					let {data} = res.data
					let list = [data];
					console.log('list22222222',list)
					getApp().globalData.searchList = list
				}
				this.AssociationListShow=false
				uni.navigateTo({
					url: './publishSearch/publishSearch'
				})
			},

			changeAssClose(){
				this.AssociationListShow=false
			},
			changeAssOpen(){
				console.log(this.keyword=='')
				if(this.keyword==''){
					this.AssociationList=[]
				}
				this.AssociationListShow=true
			},
			async AssChangeKey(val){
				// this.keyword=val
				console.log(`/twohandbook/userBook/authority/addBookToPublishByFuzzyQuery?bookId=${val}`)
				let header = new Object
				header.Authority = getApp().globalData.Authority
				var appendAss=await getApp().UniRequest(`/twohandbook/userBook/authority/addBookToPublishByFuzzyQuery?bookId=${val}`,"GET","",header)
				console.log(appendAss)
				if(appendAss.code==20000){
					this.getMayPublish();
				}
			},
			listDot(){
				let vm = this
				vm.typeshow = true
			},
			// ChengPopup(){
			// 	this.ChengseShow=true;
			// },
			ConfirmChengse(val){
				console.log(val.detail.value)
				this.PublishForm.chengse=val.detail.value;
				if(val.detail.value === '0'){
					this.PublishForm.chengse = "8~9成新"
				}else if(val.detail.value === '1'){
					this.PublishForm.chengse = "5~7成新"
				}else if(val.detail.value === '2'){
					this.PublishForm.chengse = "3~4成新"
				}
			},
			LocationPopup(){
				this.LocationShow=true;
			},
			ConfirmLocation(val1){
				console.log('val1啊啊啊啊啊啊啊啊',val1)
				this.defaultRadio = val1
				this.PublishForm.location=val1
			},
			async ConfirmPublish(publishForm,bookNumber){
				// this.show1=true;
				let vm = this;
				let header = new Object
				header.Authority = getApp().globalData.Authority
				if(getApp().globalData.wxNumber!==vm.wxNum){
					let data = await getApp().UniRequest("/twohandbook/user/authority/toBindWx?wxNumber="+vm.wxNum,"GET","",header)
					getApp().globalData.wxNumber=vm.wxNum
				}
				let isBindLocation = await getApp().UniRequest("/twohandbook/user/authority/isBindLocation","GET","",header)
				console.log('******isBindLocation.code******',isBindLocation.code)
				if(isBindLocation.code!==20000){
					wx.showToast({
					  title: '请先绑定地区',
					  icon: 'error',
					  duration: 400
					})
					this.show1=true;
					wx.hideTabBar() 
				}else{
					let isBindWx = await getApp().UniRequest("/twohandbook/user/authority/isBindWx","GET","",header)
					if(isBindWx.code==20000){
											uni.showLoading({
												title: '发布中'
											})
											let body=new Object
											body.bookId=publishForm.bookId
											body.count=bookNumber
											let data=await getApp().UniRequest(`/twohandbook/sellBookRecord/authority/sellBook`,"POST",body,header)
											console.log('发布书本的data',data)
											if(data.code === 20000){
												setTimeout(()=>{
													uni.hideLoading()
													uni.showToast({
														title:'发布成功',
														duration:2000
													});
													vm.bookDetailShow = false;
												},400)
											}
						
					}
					else {
						wx.showToast({
						  title: '请填写联系方式',
						  icon: 'error',
						  duration: 800
						})
						return
					}
				}
				
				
			},
			buttomShowClose() { 
			    this.typeshow = false
			},
			async getMayPublish(){
				console.log('#############')
				let vm = this
				let header = new Object
				header.Authority = getApp().globalData.Authority
				let res = await getApp().UniRequest("/twohandbook/userBook/authority/getPublishTextBook","GET","",header)
				console.log(res)
				console.log('#############')
				if (res.code == 20000){
					// setTimeout(()=>{
						uni.hideLoading()
						vm.bookList = res.data.data
						vm.bookListShow = vm.bookList
					// },200)
					
					
				}
			},
			async toPre(){
				let vm = this
				vm.prePubShow = true
			},
			openBookDetail(bookName,publisher,isbn,id){
		
				let vm = this
				vm.chooseBookLevel(0);
				vm.bookTitle = bookName;
				vm.publisher = publisher;
				vm.bookIsbn = isbn;
				vm.bookDetailShow = true
				vm.bookId = id;
				vm.bookNumber = 1
				vm.PublishForm.bookId=id
				vm.getTotalPrice()
			},
			closeBookDetail(){
				let vm = this
				vm.bookDetailShow = false
			},
			async addToPre(bookName,isbn,publisher,chengse,price,input,bookNumber){
				let vm = this
				vm.bookDetailShow = false;
				let preBook = new Object
				preBook.bookName = bookName;
				preBook.publisher = publisher;
				preBook.isbn = isbn;
				preBook.chengse = chengse;
				preBook.price = price;
				preBook.input = input;
				preBook.bookNumber = bookNumber;
				console.log(preBook)
				vm.preList.push(preBook)
				console.log(vm.preList)
			},
			inputPrice(event){
				console.log('!!!!!!!!')
				let vm = this;
				console.log(event)
				vm.realPrice = event
				vm.getTotalPrice();
			},
			addNumber(value){
				// console.log('#######################')
				let vm = this;
				// console.log(value)
				vm.bookNumber = value
				
				// console.log('@@@@@@@@@@@@@@@@@@@@@@@')
				vm.getTotalPrice();
			},
			closePre(){
				let vm = this;
				vm.prePubShow = false;
			},
			getTotalPrice(){
				let vm = this;
				console.log('@@@@@@@@@@@@@@@@@@@@@@@')
				console.log(vm.bookNumber)
				console.log(vm.realPrice)
				vm.totalPrice = vm.bookNumber * vm.realPrice
				console.log(vm.totalPrice)
				console.log('#######################')
			},
			async chooseBookLevel(index){
				let vm = this
				// console.log(vm.bookId)
				// console.log(index)
				// let header = new Object
				// header.Authority = getApp().globalData.Authority
				// let data = await getApp().UniRequest("/twohandbook/bookStock/getRealPrice?bookId=" + vm.bookId + "&chengse=" + index , "GET","",header)
				// console.log(data)
				// vm.realPrice = data.data.data
				// console.log(vm.realPrice)
				if(index === 0){
					vm.bookChengse = '8~9成新'
				}else if(index === 1){
					vm.bookChengse = '5~7成新'
				}else if(index === 2){
					vm.bookChengse = '1~4成新'
				}else{
					console.log('几成新这里，有bug了。。。')
				}
				vm.bookDetailButtonIndex = index
				let list = vm.bookDetailButtonCss
				list[index] = "buttonClick"
				for (let i=0;i<list.length;i++){
					if (i != index){
						list[i] = "button"
					}
				}
				vm.bookDetailButtonCss = ""
				vm.bookDetailButtonCss = list
			},
			limitNumber(oldList) {
				//当数组不合法就返回
				if (!oldList) {
					return oldList
				}
				let vm = this
				let list = new Array()
				for (let i = 0; i < oldList.length; i++) {
					let object = new Object
					object.stock = oldList[i].stock
					object.isbn=oldList[i].isbn;
					object.bookId=oldList[i].id
					let name = oldList[i].bookName
					//console.log(name)
					if (name.length >= 18) {
						name = name.slice(0, 15) + "..."
					}
					object.bookName = name
					object.number=1
					object.click=false
					list.push(object)
				}
				return list
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		
		.transition{
			position: fixed;
			width: 150rpx;
			height: 150rpx;
			// top: 1100rpx;
			left: 70rpx;
			z-index: 100;
			border-radius: 75rpx;
			background-color: #fbfbfb;
		}
		.u-safe-bottom .data-v-758fd84f{
			display: none;
		}
		.radioCss{
			position: relative;
			left: 50rpx;
			// bottom: 22rpx;
		}
		.classify{
			
			height: 500rpx;
			
			.first{
				position: relative;
				top: 20rpx;
				left: 20rpx;
				
				.firstFont{
					font-size: 35rpx;
				}
				
				.firstClassify{
					display: flex;
					.firsButton{
						margin: 20rpx;
						width: 150rpx;
						height: 45rpx;
						background-color: #ebebeb;
						text-align: center;
						border-radius: 20rpx;
					}
				}
			}
		}
		
		
		.bookDetail{
			background-color: #fcfcfc;
			width: 575rpx;
			// height: 560rpx;
			border-radius: 30rpx;
			.msg{
				position: relative;
				margin: 32rpx;
				text-align: center;
				.bookTitle{
					font-size: 40rpx;
					font-weight: 800;
					margin-bottom: 20rpx;
				}
				.isbn{
					margin-bottom: 20rpx;
				}
				.bindweixin{
					font-size: 30rpx;
					color: #1c1d1f;
					height: 105rpx;
					margin-bottom: 11rpx;
					.lianxi{
						width: 117rpx;
						height: 100rpx;
						line-height: 100rpx;
						float: left;
						
					}
					.input1{
						width: 346rpx;
						float: left;
						margin-left: 18rpx;
					}
					
				}
				.button{
					margin-bottom: 20rpx;
					border-radius: 5rpx;
					text-align: center;
					border-style: solid;
					border-color: #c8c8c8;
					color: #c8c8c8;
					border-width: 1rpx;
					border-radius: 40rpx;
					height: 70rpx;
					line-height: 2.2;
				}
				
				.buttonClick{
					margin-bottom: 20rpx;
					border-radius: 5rpx;
					text-align: center;
					border-style: solid;
					border-color: #3c9cff;
					color: #3c9cff;
					border-width: 1rpx;
					border-radius: 40rpx;
					height: 70rpx;
					line-height: 2.2;
				}
				.countBuyBookView{
					position: absolute;
					bottom: 20rpx;
					left: 20%;
				}
				.fontCss{
					position: absolute;
					left: 69%;
					bottom: 24rpx;
				}
			}
		}
		
		.head{
			position: sticky;
			top: -3rpx;
			margin-bottom: 18rpx;
			width: 100%;
			background-color: #ffffff;
			z-index: 100;
			.search{
				position: relative;
				width: 577rpx;
				top: 9rpx;
			}
			.daohanglan{
				width: 90%;
				margin: 0 auto;
			}
			.list-dot{
				position: relative;
				left: 20rpx;
				top: 10rpx;
			}
		}
		.u-demo-block__content{
			float: left;
			width: 185rpx;
		}
		.chengseCss{
			margin-bottom: 20rpx;
		}
		.textCss{
			    color: #f97272;
			    font-weight: 551;
			    margin-left: -550rpx;
			    margin-bottom: 10rpx;
			    font-size: 30rpx;
			    letter-spacing: 6rpx;
		}
		.twohandbook{
			width: 100%;
			// .book{
			// 	width: 95%;
			// 	height: 150rpx;
			// 	margin: 10rpx 20rpx;
			// 	box-shadow: 0px 0px 5px #888888;
			// 	border-radius: 20rpx;
			// }
			.progress_block {
				display: flex;
				justify-content: space-around;
				align-items: center;
				width: 93%;
				margin: auto;
				margin-bottom: 20rpx;
				border-radius: 20rpx;
				height: 156rpx;
				position: relative;
				overflow: hidden;
				background-color: #fff;
				box-shadow: 7rpx 8.5rpx 19.5rpx #DBDBDB;
				.describe {
					width: 240%;
					height: 100%;
					padding: 20rpx;
					letter-spacing: 4rpx;
			
					.name1 {
						position: relative;
						top: 25rpx;
						color: #000000;
						height: 40%;
						font-size: 36rpx;
						font-weight: 800;
						white-space:nowrap;
						overflow:hidden;
						text-overflow:ellipsis;
						width: 562rpx;
					}
			
					.value {
						position: relative;
						top: 35rpx;
						color: #000;
						font-weight: 500;
						font-size: 28rpx;
						height: 30%;
					}
				}
			
				.charts-box {
					width: 40%;
					height: 100%;
					.plus{
						margin-top:46rpx ;
						margin-right: 20rpx;
						image{
							width: 60rpx;
							
						}
					}
				}
				.block {
					background: #ffffff;  
				}
				
			}
			
		}
		.goodDetailInput{
			width: 90%;
			margin: 0 auto;
			display: flex;
			padding: 21rpx 0;
			// border-bottom: .1rpx solid #ccc;
			justify-content: space-around;
			.title{
				color: #fd4f02;
				flex: .9;
				text-align: left;
				display: flex;
				align-items: center;
				
			}
			.input2{
				width: 485rpx;
			}
			picker-view{
				// flex: 2;
				width: 485rpx;
				height: 100rpx;
			}
			 
			// 修改原有的上下边框颜色
			::v-deep .selectLine::after {
			    border-bottom: 2rpx solid #ccc;
			}
			::v-deep .selectLine::before {
			    border-top: 2rpx solid #fff;
			}
			.item{
				text-align: left;
				padding: 3rpx 19rpx;
			}
		}
		.goods_describe{
			font-size: 31rpx;
			width: 90%;
			margin-top: 20rpx;
			display: flex;
			.title{
				flex: 1;
				color: #fd4f02;
				padding-left: 4rpx;
			}
			textarea{
				width: 485rpx;
			}
		}
		.inputbtn {
			margin: 0rpx 30rpx 30rpx 30rpx;
		    // background-color: transparent;
		    // color: #fd4f02;
		    font-size: 34rpx;
			width: 60%;
	}
		.twohandbook1{
			width: 100%;
			.progress_block {
				display: flex;
				justify-content: space-around;
				align-items: center;
				width: 93%;
				margin: auto;
				margin-bottom: 20rpx;
				border-radius: 20rpx;
				// height: 100rpx;
				position: relative;
				overflow: hidden;
				background-color: #fff;
				box-shadow: 0.5rpx 0.5rpx 40rpx #DBDBDB;
			
				.describe {
					width: 240%;
					height: 100%;
					padding: 42rpx;
					letter-spacing: 4rpx;
			
					.name {
						position: relative;
						top: -5rpx;
						color: #fff;
						height: 40%;
						font-size: 40rpx;
						font-weight: 800;
					}
					
					
					.bookInfo {
						position: relative;
						top: 25rpx;
						color: #fff;
						height: 40%;
						font-size: 30rpx;
						// font-weight: 800;
					}
			
					.value {
						position: relative;
						top: 55rpx;
						color: #000;
						font-weight: 500;
						font-size: 28rpx;
						height: 30%;
					}
				}
			
				.charts-box {
					width: 40%;
					height: 100%;
					.buy{
						padding: 25rpx;
						.shopping-cart{
							margin: auto;
						}
					}
				}
				.block {
					background-color: #87CEFA;
				}
				
			}
			.progress_block:nth-child(6n+0){
				.block {
					background-color: #87CEFA;
				}
			}
			.progress_block:nth-child(6n+1){
				.block {
					background-color: #EEAEEE;
				}
			}
			.progress_block:nth-child(6n+2){
				.block {
					background-color: #FAB215;
				}
			}
			.progress_block:nth-child(6n+3){
				.block {
					background-color: #B0C4DE;
				}
			}
			.progress_block:nth-child(6n+4){
				.block {
					background-color: #9BCD9B;
				}
			}
			.progress_block:nth-child(6n+5){
				.block {
					background-color: #87CEFA;
				}
			}
		}
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
		.AssociatioPosition {
			position: fixed;
			width: 755rpx;
			display: flex;
			justify-content: center;
			z-index: 101;
			font-size: 34rpx;
			.AssociatioList{
			background-color: #ffffff;
			width: 560rpx;
			border-radius: 32rpx;
			box-shadow: 0rpx 3rpx 13rpx 3rpx #888888;
				.item{
					.AssociationListItem{
						border-bottom: #c0c1c3 1rpx solid;
						padding: 15rpx;
					}
					.AssociationListItem:hover{
						background-color: #ccc;
					}
				}
			}
			.AssociatioList1{
				height: 690rpx;
			}
		}
		.SeleButton{
			margin: 10rpx;
		}
		
		.msg1{
			width: 575rpx;
			border-radius: 30rpx;
			margin: 10rpx auto;
			font-size: 31rpx;
			letter-spacing: 4rpx;
			font-weight: 600;
			.Title{
				width: 94%;
				margin: 0 auto;
				text-align: center;
			}
			.button1{
				width: 77%;
			    margin: 38rpx auto;
			}
			.button2{
				width: 77%;
				margin: 10rpx auto;
				
			}
		}
		
</style>